<?php
session_start();
/*
 * Session variables:
 * $_SESSION['database'] [string] = database name of the current tutorial centre
 * $_SESSION['type'] [string] = user type of the logged in user
 * $_SESSION['authorised'] [boolean] = whether or not the current user is logged in
 * $_SESSION['user'] [string] = the username/ email of the logged in user
 */
if (isset($_SESSION['authorised']) && $_SESSION['authorised'] == true) {
    if (isset($_SESSION['type'])) {
        if ($_SESSION['type'] == 'administrator') {
        	include('connection.inc');
			$username=$_SESSION['manage_username'];
			$sql = "SELECT * FROM users WHERE username = '$username';";
			$result = pg_query($sql);
			$firstname = pg_fetch_result($result, 0, 'firstname');
			$middlename = pg_fetch_result($result, 0, 'middlename');
			$lastname = pg_fetch_result($result, 0, 'lastname');
			$birthday = pg_fetch_result($result, 0, 'birthday');
			$gender = pg_fetch_result($result, 0, 'gender');
			
?>
            <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                
                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    <title> Edit Profile </title>
                    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
                    <style>
                        .nav {
                            width:210px;
                            height:auto;
                            border:thin solid #09C;

                            margin-left: 10px;
                            text-align : center;}

                        .mainline {
                            width:712px;

                            height:auto;
                            text-align : center;}
                        </style>
                    </head>

                    <center>
                        <body bgcolor="#FFFFFF">
                            <div id="wrapper">
                            <div id="header">
    <h1></h1>
    </div>
    
    <div id="header2">
    	<h3></h3>
 	</div>
  

                            <div id="nav">
                                <h4>Navigation</h4>
                                <center>
                                    <script src="adminjs.js" type="text/javascript"></script><noscript><OBJECT id="adminobj" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH=230 HEIGHT=280> <PARAM NAME=movie VALUE="admin.swf"> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=opaque> <param name="scale" value="noscale" /> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="admin.swf" menu=false quality=high scale="noscale" wmode=opaque bgcolor=#FFFFFF  WIDTH=230 HEIGHT=280 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT></noscript>
                                </center>
                            </div>
                            
                            <div id="mainline">
                                <h4> Edit Profile </h4>
                                <div id="body">        
                                <h3 align="left">Required Information *</h3>                            
                                    <form enctype="multipart/form-data" name ="myform" action="admin_changeprofile.php" method="post">
                                        <table width="712" cellpadding="2" class="infotable" align="left">
                                           <tr>
												<th align="left" heigh="30" scope="row">Name:</th>
												<td><?php echo "$lastname, $firstname $middlename";?></td>
											</tr>
											<tr>
												<th align="left" height="30" scope="row">Date of Birth:</th>
												<td><?php echo $birthday;?></td>
											</tr>
											<tr>
												<th align="left" height="30" scope="row">Gender:</th>
												<td><?php echo $gender;?></td>
											</tr>
											<tr>
												<th align="left" height="30" scope="row">Email *:</th>
												<td><input type="text" size="60" maxlength="100" name="email" value="<?php echo pg_fetch_result($result, 0, 'username');?>" />
												</td>
											</tr>
											<tr>
												<th align="left" height="30" scope="row">Contact Number *:</th>
												<td><input type="text" size="30" maxlength="100" name="contact_num" value="<?php echo pg_fetch_result($result, 0, 'contactnum');?>" /></td>
											</tr>
											<tr>
												<th align="left" height="30" scope="row">Street Address 1 *:</th>
												<td><input type="text" size="60" maxlength="100"name="streetadd1" value="<?php echo pg_fetch_result($result, 0, 'streetadd1');?>" />
												</td>
											</tr>
											<tr>
												<th align="left" height="30" scope="row">Street Address 2 *:</th>
												<td><input type="text" size="60" maxlength="100" name="streetadd2" value="<?php echo pg_fetch_result($result, 0, 'streetadd2');?>" />
												</td>
											</tr>
											<tr>
												<th align="left" height="30" scope="row">City *:</th>
												<td><input type="text" size="60" maxlength="100" name="cityadd" value="<?php echo pg_fetch_result($result, 0, 'cityadd');?>" />
												</td>
											</tr>
											
							
                                            <tr align="left">
                                                <td></td>
                                                <td><input name="submit" type="submit" value="Save Changes" /></td>
                                            </tr>
                                        </table>
                                    </form>
                                
                            <p align="justify"><br /></p>
                        </div>

                        <br class="clearfloat"/>
                        <br />

</div>
 <div id="footer">
                            <p align="center">
                                Tutorial Business Manager: info@tbms.com <br />Credits/Engineers: Aquino, Chloebelle; Dela Cruz, Roy Erwin; Maliwanag, Ranyel Bryan; Manzano, Audrey Ann; Ng, Sheila Regine<br />
                                <br />copyright 2011</p>
                        </div>
                        </div>
                    </body>
                </center>
            </html>
<?php
        } elseif ($_SESSION['type'] == 'student') {
            header('Location: student_index.php');
            exit();
        } elseif ($_SESSION['type'] == 'tutor') {
            header('Location: tutor_index.php');
            exit();
        } elseif ($_SESSION['type'] == 'parent') {
            header('Location: parent_index.php');
            exit();
        }
    }
} else {
    header('Location: index.php');
}
?>
